package com.donfu.web.controller.wxhouse;

import com.donfu.common.core.controller.BaseController;
import com.donfu.common.core.domain.AjaxResult;
import com.donfu.system.service.house.IHouseOrderGoodsService;
import com.donfu.system.service.house.IHouseOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Auther: 覃创斌
 * @Date: 2021/12/20 18:09
 * @Description: 订单
 */
@RestController
@RequestMapping("/wx/order")
public class WebHouseOrderController extends BaseController {
    @Autowired
    private IHouseOrderService orderService;

    @Autowired
    private IHouseOrderGoodsService orderGoodsService;

    @PostMapping("/orderList")
    public AjaxResult orderList(@RequestParam (value="userId") Integer userId, Integer orderStatus)
    {
        List<Map<String,Object>> orderInfoList = orderService.getMyOrderList(userId,orderStatus);
        for (int i = 0; i < orderInfoList.size(); i++) {
            Map<String,Object> orderMap = orderInfoList.get(i);
            Long id = Long.parseLong(orderMap.get("id").toString());
            List<Map<String,Object>> orderGoodsList = orderGoodsService.getMyOrderList(id);
            orderMap.put("goodsList",orderGoodsList);
        }
        return AjaxResult.success(orderInfoList);
    }
}
